/**
 *******************************************************************************
 * @FileName  : tlsr825x_timer.h
 * @Author    : GaoQiu
 * @CreateDate: 2020-09-10
 * @Copyright : Copyright(C) GaoQiu
 *              All Rights Reserved.
 *
 *******************************************************************************
 *
 * The information contained herein is confidential and proprietary property of
 * GaoQiu and is available under the terms of Commercial License Agreement
 * between GaoQiu and the licensee in separate contract or the terms described
 * here-in.
 *
 * This heading MUST NOT be removed from this file.
 *
 * Licensees are granted free, non-transferable use of the information in this
 * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
 *
 *******************************************************************************
 */

#ifndef TLSR825X_TIMER_H_
#define TLSR825X_TIMER_H_

#include "tlsr825x.h"


/******************************************************************************/
/*                                                                            */
/*  !!! Watchdog and timer 2 cannot be used at the same time                  */
/*                                                                            */
/******************************************************************************/


/*!  timer id. */
#define TIM0     0
#define TIM1     1
#define TIM2     2

/*!  Timer Mode */
#define TIM_Mode_Sys_Clk        0x00
#define TIM_Mode_Gpio_Trig      0x01
#define TIM_Mode_Plus_Width     0x02
#define TIM_Mode_Tick           0x03

/**
 * @brief : Timer initialization
 * @param : TIMx      can be TIM0/TIM1/TIM2 ...
 * @param : TIM_Mode  can be TIM_Mode_Sys_Clk/TIM_Mode_Gpio_Trigg ...
 * @return: none.
 */
void TIM_Init(uint8_t TIMx, uint8_t TIM_Mode);

/**
 * @brief : Timer enable/disable.
 * @param : TIMx      can be TIM0/TIM1/TIM2 ...
 * @param : enable    true/false.
 * @return: none.
 */
void TIM_Cmd(uint8_t TIMx, bool_t enable);

/**
 * @brief : Timer counter.
 * @param : TIMx      can be TIM0/TIM1/TIM2 ...
 * @param : counter
 * @return: none.
 */
void TIM_SetCounter(uint8_t TIMx, uint32_t counter);

/**
 * @brief : Set Timer counter.
 * @param : TIMx      can be TIM0/TIM1/TIM2 ...
 * @param : cap
 * @return: none.
 */
void TIM_SetCapture(uint8_t TIMx, uint32_t cap);

/**
 * @brief : Timer get interrupt flag.
 * @param : TIMx      can be TIM0/TIM1/TIM2 ...
 * @return: none.
 */
uint8_t TIM_GetITFlag(uint8_t TIMx);

/**
 * @brief : Timer clear interrupt flag.
 * @param : TIMx      can be TIM0/TIM1/TIM2 ...
 * @return: none.
 */
void TIM_ClearITFlag(uint8_t TIMx);


#endif /* TLSR825X_TIMER_H_ */
